package org.act.xservices.rt.xcontainer.message.worker;

import org.act.xservices.rt.xcontainer.framework.IConnector;
import org.act.xservices.rt.xcontainer.framework.dispatcher.ADispatchWorkerFactory;
import org.act.xservices.rt.xcontainer.framework.dispatcher.ISafeDispatchWorker;
import org.act.xservices.rt.xcontainer.inf.context.IMessageContext;
import org.act.xservices.rt.xcontainer.message.handler.MessagePoolHandler;


/**
 * @LastModifyTime 2008-7-7
 * @CreationTime 2007-05-28
 * @author Lizq [lizq@act.buaa.edu.cn]
 * @since JDK1.5
 */
public class MessageOutWorkerFactory extends ADispatchWorkerFactory<IMessageContext> {
	
	
	private MessagePoolHandler messagePoolHandler;
	
	
	
	public MessagePoolHandler getMessagePoolHandler() {
	
		return messagePoolHandler;
	}

	
	public void setMessagePoolHandler(MessagePoolHandler messagePoolHandler) {
	
		this.messagePoolHandler = messagePoolHandler;
	}

	public MessageOutWorkerFactory(IConnector connector){
		super(connector);
	}

	@SuppressWarnings("unchecked")
	@Override
	public final ISafeDispatchWorker createSafeDispatchWorker(IMessageContext x) {
		MessageOutWorker messageOutWorker = 
			new MessageOutWorker(this.getConnector());
		
		messageOutWorker.setMessageContext(x);
		messageOutWorker.setMessagePoolHandler(messagePoolHandler);
		return messageOutWorker;
	}
}
